#ifndef _SOUNDMANAGER_H
#define _SOUNDMANAGER_H

#include <string>
#include <map>

#include <fmod/fmod.hpp>
#include <fmod/fmod_errors.h>

#include "GameInfo.h"

#include "StringUtils.h"
#include "Logger.h"

#include "Singleton.h"
#include "Sound.h"

#include "Vector3.h"

#ifdef GALLIUMENGINE_DLL 
#define GALLIUMENGINE_API __declspec( dllexport )
#else
#define GALLIUMENGINE_API __declspec( dllimport )
#endif

namespace GalliumEngine
{

	namespace SOUND_TYPE
	{
		enum GALLIUMENGINE_API SOUNDTYPE
		{
			SOUND_TYPE_INVALID = 0,
			SOUND_TYPE_3D_SOUND,
			SOUND_TYPE_3D_SOUND_LOOPED,
			SOUND_TYPE_2D_SOUND,
			SOUND_TYPE_2D_SOUND_LOOPED,
		};
	}
 
	class SoundManager : public Singleton<SoundManager>
	{
	private:
		typedef std::map<std::string,Sound*> sound_map;
		typedef sound_map::iterator sound_map_itr;
		typedef sound_map::const_iterator sound_map_const_itr;
		typedef std::pair<std::string,Sound*> sound_pair;

		sound_map sounds;

		FMOD::System* system;
		FMOD_RESULT result;
		unsigned int version;
		int numdrivers;
		FMOD_SPEAKERMODE speakermode;
		FMOD_CAPS caps;
		char name[256];

		bool initialized;
	public:
		GALLIUMENGINE_API SoundManager(void);
		GALLIUMENGINE_API ~SoundManager(void);
		GALLIUMENGINE_API bool initialize();
		GALLIUMENGINE_API void deInitialize();

		GALLIUMENGINE_API Sound* getSound(std::string _id);

		GALLIUMENGINE_API void createSound(std::string id, std::string fileName, SOUND_TYPE::SOUNDTYPE soundType);
	
		GALLIUMENGINE_API void createSound(std::string id, std::string fileName);
		GALLIUMENGINE_API void createStream(std::string id, std::string fileName);
		GALLIUMENGINE_API void createLoopedSound(std::string id, std::string fileName);
		GALLIUMENGINE_API void createLoopedStream(std::string id, std::string fileName);

		GALLIUMENGINE_API FMOD::System* getSystem();

		GALLIUMENGINE_API void setListenerAttributes(Vector3 position,
		Vector3 velocity,
		Vector3 forward,
		Vector3 up);
	};
}

#endif

